package com.gadgets.framework;

import com.gadgets.framework.task.WoodenGeneratorTask;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 功能说明：
 *
 * @author Unclexiu
 * @version V202101.00.000
 * @data 2022-07-18
 * 修改记录：  修改日期          修改人员    修改说明
 * 2022-07-18  xiujunqing   创建文件
 */
@Configuration
public class QuartzConfig {

	@Value("${gadgets.fm04.wooden.speed}")
	private String cron;

	@Bean
	public JobDetail quartzTestDetail(){
		return JobBuilder.newJob(WoodenGeneratorTask.class)
				.withIdentity("woodenGenerator","WOODEN_GENERATOR")
				.storeDurably().build();
	}

	@Bean
	public Trigger quartzJobTrigger(){
		CronScheduleBuilder builder = CronScheduleBuilder.cronSchedule(cron);
		return TriggerBuilder.newTrigger()
				.forJob(quartzTestDetail())
				.withIdentity("woodenGeneratorTrigger","WOODEN_GENERATOR_TRIGGER")
				.withSchedule(builder)
				.build();
	}

}
